<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<JobProviderSearchData>" %>
<%@ Import Namespace="RecruitmentAgency.Models.DataTypes"%>
<%@ Import Namespace="RecruitmentAgency.Models.Utilities.Paging"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Connections - Search job providers
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="centre">
        <% using (Html.BeginForm()) {%>
            <div class="panelTop"></div>
            <div class="panelMiddle padLR20">
                <div class="titleLabel">Search job providers</div>
                Fill one or more fields to search for specific companies, or leave all fields blank to view all of them.
                <div class="formColumn">                    
                    <div class="formLabel">
                        <label for="FirstName">Contact first name:</label>
                    </div>
                    <%= Html.TextBox("FirstName")%>
                    <div class="formLabel">
                        <label for="LastName">Contact last name:</label>
                    </div>
                    <%= Html.TextBox("LastName")%>
                    <div class="formLabel">
                        <label for="CompanyName">Company name:</label>
                    </div>
                    <%= Html.TextBox("CompanyName")%>
                </div>
                <div class="formColumn">                    
                    <div class="formLabel">
                        <label for="RegistrationNumber">Registration number:</label>
                    </div>
                    <%= Html.TextBox("RegistrationNumber")%>
                    <div class="formLabel">
                        <label for="City">Company city:</label>
                    </div>
                    <%= Html.TextBox("City")%>
                    <input name="searchComapnyButton" class="formButton" id="searchComapnyButton" type="submit" value="Search" />
                </div>
            </div>
            <div class="panelBottom"></div>
        <% } %>    
        <div class="panelTop"></div>
        <div class="panelMiddle padLR20">
            <div class="shortTitleLabel">Results</div>
            <div class="floatRight inline marginT5">
                <div class="inline">Number of results in each page: </div>
                <%= Html.DropDownList("PageSize", (SelectList)ViewData["pageSizes"], new { @class = "pageSizeList", onchange = "javascript:location.href='?pageSize=' + this.options[this.selectedIndex].value" })%>
            </div>
            <% foreach (var item in Model.Results) { %>
                <div class="result green" onmouseover="highlightResult(this)" onclick="location.href='/JobProvider/ViewCompany/<%= item.JobProviderId %>'" onmouseout="normalResult(this)" title="Click to view this company.">
                    <b><%= Html.Encode(item.CompanyName) %></b>
                    (<a href="http://www.<%= Html.Encode(item.WebsiteUrl) %>" title="Click to go to <%= Html.Encode(item.FirstName) %> <%= Html.Encode(item.LastName) %>'s website.">www.<%= Html.Encode(item.WebsiteUrl)%></a>)
                    - contact: 
                    <b><%= Html.Encode(item.FirstName) %> <%= Html.Encode(item.LastName) %></b>
                    <a href="mailto:<%= Html.Encode(item.Email) %>" title="Click to send an e-mail to <%= Html.Encode(item.FirstName) %> <%= Html.Encode(item.LastName) %>."><%= Html.Encode(item.Email)%></a>
                    <div class="floatRight">
                        <% if (ViewData["role"].ToString() == "Admin") { %>
                            <%= Html.ActionLink("Edit", "Edit", new { id = item.JobProviderId })%> |
                            <%= Html.ActionLink("Delete", "Delete", new { id = item.JobProviderId })%>
                        <% } %>                                            
                    </div>
                </div>
            <% } %>
            <% if (Model.Results.Count == 0) { %>
                <div class="floatLeft clear">There are no companies that match that search selection.</div>
            <% } else { %>
                <div class="floatLeft inline marginT10 clear">Showing <%= Model.PageSize > Model.TotalResultCount ? Model.TotalResultCount : Model.PageSize%> out of <%= Model.TotalResultCount %> results.</div>
                <div class="pager">
                    Page number <%= Model.PageNumber %> out of <%= Math.Ceiling((decimal)Model.TotalResultCount / Model.PageSize) %> <%= Html.Pager(ViewData.Model.PageSize, ViewData.Model.PageNumber, ViewData.Model.TotalResultCount) %>
                </div>
            <% } %>
        </div>        
        <div class="panelBottom"></div>
    </div>
</asp:Content>